home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / util / libs / image.lha / Image / Image_lib / lib_source / LibInit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-28  |  2.9 KB  |  138 lines

  1. /*
  2. **      $VER: LibInit.c 37.11 (24.6.97)
  3. **
  4. **      Library initializers and functions to be called by StartUp.c
  5. **
  6. **      (C) Copyright 1996-97 Andreas R. Kleinert
  7. **      All Rights Reserved.
  8. */
  9.  
  10. #define __USE_SYSBASE
  11.  
  12. #include <exec/types.h>
  13. #include <exec/memory.h>
  14. #include <exec/libraries.h>
  15. #include <exec/execbase.h>
  16. #include <exec/resident.h>
  17. #include <exec/initializers.h>
  18. #include <proto/exec.h>
  19.  
  20. #include "/include/libraries/imagebase.h"
  21.  
  22. ULONG __saveds __stdargs StartLib(void);
  23. void  __saveds __stdargs EndLib(void);
  24.  
  25. extern struct ImageBase *ImageBase;
  26. struct ExecBase     *SysBase     = NULL;
  27. struct Library      *UtilityBase = NULL;
  28. struct GfxBase      *GfxBase     = NULL;
  29.  
  30. #define VERSION  40
  31. #define REVISION 0
  32.  
  33. char __aligned ExLibName [] = "image.library";
  34.  
  35. #ifdef _M68060
  36. #define __CPU "68060"
  37. #else
  38. #ifdef _M68040
  39. #define __CPU "68040"
  40. #else
  41. #ifdef _M68030
  42. #define __CPU "68030"
  43. #else
  44. #ifdef _M68020
  45. #define __CPU "68020"
  46. #else
  47. #ifdef _M68010
  48. #define __CPU "68010"
  49. #else
  50. #define __CPU "68000"
  51. #endif
  52. #endif
  53. #endif
  54. #endif
  55. #endif
  56.  
  57. char __aligned ExLibID   [] = "image.library 40.00 -  "__CPU" ("__AMIGADATE__" "__TIME__")";
  58.  
  59.  
  60. char __aligned Copyright [] = "© 1993-99 Paweî Marciniak";
  61.  
  62. extern ULONG InitTab[];
  63.  
  64. extern APTR EndResident;
  65.  
  66. struct Resident __aligned ROMTag =
  67. {
  68.  RTC_MATCHWORD,
  69.  &ROMTag,
  70.  &EndResident,
  71.  RTF_AUTOINIT,
  72.  VERSION,
  73.  NT_LIBRARY,
  74.  0,
  75.  &ExLibName[0],
  76.  &ExLibID[0],
  77.  &InitTab[0]
  78. };
  79.  
  80. APTR EndResident;
  81.  
  82. struct MyDataInit
  83. {
  84.  UWORD ln_Type_Init;
  85.  UWORD ln_Type_Offset;
  86.  UWORD ln_Type_Content;
  87.  UBYTE ln_Name_Init;
  88.  UBYTE ln_Name_Offset;
  89.  ULONG ln_Name_Content;
  90.  UWORD lib_Flags_Init;
  91.  UWORD lib_Flags_Offset;
  92.  UWORD lib_Flags_Content;
  93.  UWORD lib_Version_Init;
  94.  UWORD lib_Version_Offset;
  95.  UWORD lib_Version_Content;
  96.  UWORD lib_Revision_Init;
  97.  UWORD lib_Revision_Offset;
  98.  UWORD lib_Revision_Content;
  99.  UBYTE lib_IdString_Init;
  100.  UBYTE lib_IdString_Offset;
  101.  ULONG lib_IdString_Content;
  102.  ULONG ENDMARK;
  103. } DataTab =
  104. {
  105.  INITBYTE(OFFSET(Node,         ln_Type),      NT_LIBRARY),
  106.  0x80, (UBYTE) OFFSET(Node,    ln_Name),      (ULONG) &ExLibName[0],
  107.  INITBYTE(OFFSET(Library,      lib_Flags),    LIBF_SUMUSED|LIBF_CHANGED),
  108.  INITWORD(OFFSET(Library,      lib_Version),  VERSION),
  109.  INITWORD(OFFSET(Library,      lib_Revision), REVISION),
  110.  0x80, (UBYTE) OFFSET(Library, lib_IdString), (ULONG) &ExLibID[0],
  111.  (ULONG) 0
  112. };
  113.  
  114. ULONG __saveds __stdargs StartLib(void)
  115. {
  116.  SysBase = (*((struct ExecBase **) 4));
  117.  
  118.  UtilityBase = OpenLibrary("utility.library", 37);
  119.  if(!UtilityBase) return(FALSE);
  120.  
  121.  GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 39);
  122.  if(!GfxBase) return(FALSE);
  123.  
  124.  
  125.  ImageBase->ib_SysBase       = SysBase;
  126.  
  127.  ImageBase->ib_UtilityBase = UtilityBase;
  128.  ImageBase->ib_GfxBase       = GfxBase;
  129.  
  130.  return(TRUE);
  131. }
  132.  
  133. void __saveds __stdargs EndLib(void)
  134. {
  135.  if(GfxBase)     CloseLibrary((struct Library *) GfxBase);
  136.  if(UtilityBase) CloseLibrary((struct Library *) UtilityBase);
  137. }
  138.